<?php


namespace App\Controller\Client;


use App\Controller\AbstractController;
use App\Request\Client\User\BindAlipayRequest;
use App\Request\Client\User\BindOpenidRequest;
use App\Request\Client\User\GoldListRequest;
use App\Request\Client\User\InfoPasswordUpdateRequest;
use App\Request\Client\User\InfoUpdateRequest;
use App\Request\Client\User\WithdrawListRequest;
use App\Request\Client\User\WithdrawRequest;
use App\Service\Client\UserService;
use Hyperf\Di\Annotation\Inject;

class UserController extends AbstractController
{
    /**
     * @Inject()
     * @var UserService
     */
    protected $userService;

    /**
     * 个人信息
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function info()
    {
        $data = $this->userService->info();
        return $this->response->success($data);
    }

    /**
     * 个人信息-修改
     * @param InfoUpdateRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function infoUpdate(InfoUpdateRequest $request)
    {
        $validator = $request->validated();
        $this->userService->infoUpdate($validator);
        return $this->response->success();
    }


    /**
     * 个人密码修改
     * @param InfoPasswordUpdateRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function infoPasswordUpdate(InfoPasswordUpdateRequest $request)
    {
        $validator = $request->validated();
        $this->userService->infoPasswordUpdate($validator);
        return $this->response->success();
    }


    /**
     * 金币列表
     * @param GoldListRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function goldList(GoldListRequest $request)
    {
        $validator = $request->validated();
        $data = $this->userService->goldList($validator);
        return $this->response->success($data);
    }

    /**
     * 金币提现
     * @param WithdrawRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function withdraw(WithdrawRequest $request)
    {
        $validator = $request->validated();
        $this->userService->withdraw($validator);
        return $this->response->success();
    }

    /**
     * 提现列表
     * @param WithdrawListRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function withdrawList(WithdrawListRequest $request)
    {
        $validator = $request->validated();
        $data = $this->userService->withdrawList($validator);
        return $this->response->success($data);
    }

    /**
     * 绑定支付宝
     * @param BindAlipayRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function bindAlipay(BindAlipayRequest $request)
    {
        $validator = $request->validated();
        $this->userService->bindAlipay($validator);
        return $this->response->success();
    }

    /**
     * 绑定微信
     * @param BindOpenidRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function bindOpenid(BindOpenidRequest $request){
        $validator = $request->validated();
        $this->userService->bindOpenid($validator);
        return $this->response->success();
    }

}